//
//  UIView_Extension.swift
//  swiftProductTemplate
//
//  Created by 刘圣洁 on 2025/6/19.
//

import UIKit

extension UIView {
    // 加载NIB文件
    class func fromNib<T: UIView>() -> T {
        return Bundle(for: T.self).loadNibNamed(String(describing: T.self), owner: nil, options: nil)?.first as! T
    }
    
    // 添加阴影
    func addShadow(color: UIColor = .black, offset: CGSize = CGSize(width: 0, height: 2), opacity: Float = 0.5, radius: CGFloat = 5.0) {
        layer.shadowColor = color.cgColor
        layer.shadowOpacity = opacity
        layer.shadowRadius = radius
        layer.shadowOffset = offset
        layer.masksToBounds = false
    }
    
    // 添加圆角
    func roundCorners(_ radius: CGFloat) {
        layer.cornerRadius = radius
        layer.masksToBounds = true
    }
}    
